﻿#include<stdio.h>
void num();
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		num();
	}
	return 0;
}
void num() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int cont = 0;
	for (int j = 1000; j <= 9999; j++) {	
		if ((j % a == 0) && ((j + 1) % b == 0) && ((j + 2) % c == 0)) {
			cont += 1;
			printf("%d", j);
			break;
		}
	}
		if (cont == 0) {
			printf("The ans is Impossible");
		}		
}

